import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import moment from "moment";

@Injectable()
export class RosterFliterProvider {
    constructor (private http: HttpClient ) {}

    getAllActivity (params, notLoading) {
        let url = `/campaign/v1/app/list?notLoading=${notLoading}&classify=${params.classify}`;
        if (params.startTime) {
            url += `&startTime=${moment(params.startTime).unix()}`;
        }
        if (params.endTime) {
            url += `&endTime=${moment(`${params.endTime} 23:59:59`).unix()}`;
        }
        params.type.forEach((type) => {
            url += `&type=${type}`;
        });
        params.status.forEach((status) => {
            url += `&status=${status}`;
        });
        return this.http.get(url);
    }

    getAllActivityType (notLoading=1) {
        return this.http.get(`/campaign/v1/compaignType?notLoading=${notLoading}`);
    }
}
